Fourier-domain BANE#206
Conversation
|
Need to include |
|
I'm getting an error when running that i'm not sure how to fix: I'm not savvy enough with |
|
@PaulHancock what versions of Numpy and Numba are you rocking? |
|
Ah sorry @PaulHancock, I remembered some extra steps to get this to work. Using Numba and Numpy-FFT also requires rocket-fft. It's a little sneaky since no import is required! So the fix is a |
|
Thanks @AlecThomson it's working now. |
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a Fourier-based implementation of BANE, adding tests, packaging updates, a CLI script, and a numba-based polynomial fit utility.
- Added unit tests for pad_reflect, FFT smoothing, bane_fft, and robust_bane
- Updated setup.py to include new dependencies and register the BANE_fft script
- Created scripts/BANE_fft CLI wrapper and added AegeanTools/numba_polyfit.py
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| tests/unit/test_bane_fft.py | Added fixtures and tests for pad_reflect, FFT, bane_fft, robust_bane |
| setup.py | Bumped numpy range, added rocket-fft, numba, radio-beam, and CLI script registration |
| scripts/BANE_fft | New entry-point script invoking the Fourier-based BANE CLI |
| AegeanTools/numba_polyfit.py | New module providing numba-accelerated polynomial fitting |
Comments suppressed due to low confidence (1)
AegeanTools/numba_polyfit.py:30
- Variable name 'det_' is misleading—it holds the coefficients from lstsq, not a determinant. Consider renaming to 'coeffs' or 'coef'.
det_ = np.linalg.lstsq(a, b)[0]
|
|
||
|
|
||
| @pytest.fixture | ||
| def ranmdom_arrays() -> RandomArrays: |
There was a problem hiding this comment.
The fixture name 'ranmdom_arrays' appears to have a typo. Rename it to 'random_arrays' for clarity.
| def ranmdom_arrays() -> RandomArrays: | |
| def random_arrays() -> RandomArrays: |
|
|
||
|
|
||
| @pytest.fixture | ||
| def ranmdom_arrays_odd() -> RandomArrays: |
There was a problem hiding this comment.
The fixture name 'ranmdom_arrays_odd' has the same typo. Rename it to 'random_arrays_odd' to match intent.
| def ranmdom_arrays_odd() -> RandomArrays: | |
| def random_arrays_odd() -> RandomArrays: |
| def test_bane_fft(ranmdom_arrays: RandomArrays): | ||
| gaussian_kernel_arr = gaussian_kernel(10) | ||
| for array, loc, scale in zip( | ||
| ranmdom_arrays.arrays, ranmdom_arrays.locs, ranmdom_arrays.scales, strict=False |
There was a problem hiding this comment.
The 'strict' parameter for zip was introduced in Python 3.10. Since the project supports >=3.8, this will error on 3.8–3.9. Consider removing 'strict=False' or raising your minimum Python to 3.10.
| ranmdom_arrays.arrays, ranmdom_arrays.locs, ranmdom_arrays.scales, strict=False | |
| ranmdom_arrays.arrays, ranmdom_arrays.locs, ranmdom_arrays.scales |
| for array, loc, scale in zip( | ||
| ranmdom_arrays.arrays, ranmdom_arrays.locs, ranmdom_arrays.scales, strict=False |
There was a problem hiding this comment.
Same issue here: 'strict=False' in zip requires Python 3.10+. Remove it or bump the Python requirement.
| for array, loc, scale in zip( | |
| ranmdom_arrays.arrays, ranmdom_arrays.locs, ranmdom_arrays.scales, strict=False | |
| for array, loc, scale in zip_safe( | |
| ranmdom_arrays.arrays, ranmdom_arrays.locs, ranmdom_arrays.scales |
| import matplotlib.pyplot as plt | ||
|
|
There was a problem hiding this comment.
[nitpick] matplotlib is only used in the demo under main. Move this import inside the main block to avoid imposing an unnecessary runtime dependency.
| import matplotlib.pyplot as plt |
Hi @PaulHancock,
@tjgalvin and I have been experimenting with using a Fourier approach for BANE. The motivation for this was to boost the speed, especially when running on large cubes (such as those produced for polarisation products). We were also inspired by the Fourier approach used by WSClean for background/noise estimation.
I've put together a performant script that uses Numba for some very nice speed ups. This approach can blast through large cubes in short order. I've also added some options for handling 3D and 4D cubes which might be useful for regular BANE too.
The last outstanding issue is that is seems that output images are offset up and right by the size of the convolution kernel (a.k.a box size). I'll need to do some deeper digging to figure out how to fix that. In the meantime if you have any thoughts on that, please let me know!
Anyway, I'd be really keen to get your thoughts on this kind of approach :)